package cn.idietrade.idletrademessagemodule8006.controller;

import cn.idietrade.common.utils.ReturnResultData;
import cn.idietrade.idletrademessagemodule8006.service.MessageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 作者：李永康
 * @createTime 2022/12/7 15:26
 * @description 描述
 */
@RestController
public class MessageController {
    @Resource
    private MessageService messageService;
    @RequestMapping("/guestBook")
    public ReturnResultData addMessage(Integer sendUserId,  Integer recvUserId,
                                       String content, Integer goodsId){
        ReturnResultData resultData = new ReturnResultData();
        int result = messageService.addMessage(sendUserId, recvUserId, content, goodsId);
        if(result>0){
            resultData.setMessage("留言成功！");
            resultData.setData(result);
            resultData.setCode(1);
        }else{
            resultData.setMessage("留言失败！");
            resultData.setData(result);
            resultData.setCode(0);
        }
        return resultData;
    }
}
